
// import oimo.m.Vec3;
// import oimo.m.M;
// import oimo.common.MathUtil;
// import oimo.dynamics.constraint.info.JacobianRow;
// import oimo.dynamics.constraint.joint.JointImpulse;

import { JacobianRow } from "../JacobianRow";
import { JointImpulse } from "../../joint/JointImpulse";
import { MathUtil } from "../../../../common/MathUtil";

/**
 * numberernal class.
 */
export class JointSolverInfoRow {
	/** Used for both velocity and position solver. */
	jacobian: JacobianRow;

	/** Used for both velocity and position solver. */
	rhs: number;

	/** Used for velocity solver. */
	cfm: number;

	/** Used for both velocity and position solver. */
	minImpulse: number;
	/** Used for both velocity and position solver. */
	maxImpulse: number;

	/** Used for velocity solver. */
	motorSpeed: number;
	/** Used for velocity solver. */
	motorMaxImpulse: number;

	/** Used for both velocity and position solver. */
	impulse: JointImpulse;

	constructor() {
		this.jacobian = new JacobianRow();
		this.rhs = 0;
		this.cfm = 0;
		this.minImpulse = 0;
		this.maxImpulse = 0;
		this.motorSpeed = 0;
		this.motorMaxImpulse = 0;
		this.impulse = null;
	}


	public clear(): void {
		this.jacobian.clear();
		this.rhs = 0;
		this.cfm = 0;
		this.minImpulse = 0;
		this.maxImpulse = 0;
		this.motorSpeed = 0;
		this.motorMaxImpulse = 0;
		this.impulse = null;
	}


	public equalLimit(rhs: number, cfm: number): void {
		this.rhs = rhs;
		this.cfm = cfm;
		this.minImpulse = MathUtil.NEGATIVE_INFINITY;
		this.maxImpulse = MathUtil.POSITIVE_INFINITY;
	}


	public motor(speed: number, maxImpulse: number): void {
		this.motorSpeed = speed;
		this.motorMaxImpulse = maxImpulse;
	}
}
